Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exp init: add basic template support #6630

Closed
wants to merge 5 commits into from

Conversation

skshetry
Copy link
Member

@skshetry skshetry commented Sep 16, 2021

This adds basic support for templating on dvc exp init.
interactive and explicit are not supported yet. The custom templates are supported,
but right now, as we don't initialize it in dvc init, it has to be added manually in .dvc/stages by the
user. I don't want to add that support yet before having this stable, as we may have some backward incompatible changes, so for testing, you'd have to do mkdir .dvc/stages yourself for a while.

The default templates are not usable yet for binary packages users.
Note that the stage is appended after the template has been parsed, validated and then processed by stage when dumping, so it may not reflect the template very well, there may be formatting differences.

I tried using direct updates first, but doing that, it leaves formatting issues generated by templates (like whitespaces, empty newlines, etc.) and comment gets left-shifted. So, I went with the stage.dump() option. We could roll back to it if we want to in the future.

In terms of code, all of the stuff related to initialization has been moved to experiments.init module, but I am still hesitant to add it to repo.experiments as a new API.

Also, it adds a dependency on jinja2. Regarding tests, I have only added simple ones and I don't plan to add until this feature starts taking shape.

The template is not usable yet in packages nor it will
be initialized during 'dvc init' though. But it supports
custom templates if user adds the template in .dvc/stages
or in dvc's codebase on resources/stages.
@skshetry skshetry added A: experiments Related to dvc exp A: cli Related to the CLI labels Sep 16, 2021
@skshetry skshetry requested a review from a team as a code owner September 16, 2021 11:02
@skshetry skshetry requested a review from pared September 16, 2021 11:02
@pared
Copy link
Contributor

pared commented Sep 17, 2021

LGTM so far,
I have a question regarding:

The default templates are not usable yet for binary packages users.

Did you already think about how to include that support? I have a similar problem in #6550 and my research led me to pkg_resources. I guess it would be good to agree on some convention.

@dberenbaum
Copy link
Collaborator

Did you already think about how to include that support? I have a similar problem in #6550 and my research led me to pkg_resources. I guess it would be good to agree on some convention.

Yes, it would be great to maintain consistency with #6550 and #4410.

@skshetry
Copy link
Member Author

This is stale, superseded by #6681.

@skshetry skshetry closed this Sep 24, 2021
@skshetry skshetry deleted the exp-init-templates branch September 24, 2021 09:27
@skshetry
Copy link
Member Author

skshetry commented Sep 24, 2021

Did you already think about how to include that support?

@pared, I have not researched about this yet, as I don't want to add the support till we are done with all the changes with exp init. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: cli Related to the CLI A: experiments Related to dvc exp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants